﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security;
using Epi;
using CDC.SampleShell.Infrastructure;

namespace CDC.SampleShell.Domain
{
    public class FormRecordDictionary : Dictionary<View, List<Record>>
    {
        public Record GetRecordByGuid(Guid guid)
        {
            foreach (KeyValuePair<View, List<Record>> kvp in this)
            {
                foreach (Record record in kvp.Value)
                {
                    if (record.GlobalRecordId.Equals(guid))
                    {
                        return record;
                    }
                }
            }

            throw new InvalidOperationException();
        }

        public void RemoveRecord(Guid guid)
        {
            Record recordToRemove = GetRecordByGuid(guid);
            View form = recordToRemove.Form;

            this[form].Remove(recordToRemove);
        }
    }
}
